(*
  Copyright (c) 2009 Barry Schwartz

  Permission is hereby granted, free of charge, to any person
  obtaining a copy of this software and associated documentation
  files (the "Software"), to deal in the Software without
  restriction, including without limitation the rights to use,
  copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the
  Software is furnished to do so, subject to the following
  conditions:

  The above copyright notice and this permission notice shall be
  included in all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  OTHER DEALINGS IN THE SOFTWARE.
*)

open Pycaml
open XNum
  
(* One inch in points. *)
val inch : num
  
val infinite : num
val minus_infinite : num
  
(* Badness is a measure of how bad a scaled box looks. *)

(* "badness ratio" calculates the badness of a box from its adjustment ratio. *)
val badness : num -> num
  
(* A dimension consists of a base value and the amount it can grow or
   shrink.  All values are in units of point. *)
type dim = {
  d_base           : num;
  d_stretch_factor : num;
  d_stretch_order  : int;
  d_shrink_factor  : num;
  d_shrink_order   : int
} (* with sexp *)

type xdim = private {
  xd_base    : num;
  xd_stretch : (num * int) list;
  xd_shrink  : (num * int) list
} (* with sexp *)

val fixed_dim : num -> dim
val dim_zero : dim
val dim_1pt : dim
val dim_12pt : dim
val dim_fil : dim
val dim_fill : dim
val dim_ss : dim
val dim_filneg : dim
val xdim_zero : xdim
val xdim_stretch : xdim -> (num * int)
val xdim_shrink : xdim -> (num * int)
val xdim_to_dim : xdim -> dim
val dim_to_xdim : dim -> xdim
val dim_equal : dim -> dim -> bool
val dim_is_zero : dim -> bool
val log_dim : dim -> unit
val dim_add : dim -> dim -> dim
val dim_neg : dim -> dim
val dim_sub : dim -> dim -> dim
val dim_mult : num -> dim -> dim
val xdim_add : xdim -> xdim -> xdim
val xdim_neg : xdim -> xdim
val xdim_sub : xdim -> xdim -> xdim
val xdim_mult : num -> xdim -> xdim
val xdim_add_dim : xdim -> dim -> xdim
val xdim_sub_dim : xdim -> dim -> xdim
val dim_max : dim -> dim -> dim
val dim_min : dim -> dim -> dim
val dim_max_stretch : dim -> num
val dim_max_shrink : dim -> num
val xdim_max_stretch : xdim -> num
val xdim_max_shrink : xdim -> num
val xdim_select_order : xdim -> int -> int -> dim
val dim_max_value : dim -> num
val dim_min_value : dim -> num
val xdim_max_value : xdim -> num
val xdim_min_value : xdim -> num
  
(* stretching and shrinking dimensions *)
val dim_shift_base : dim -> num -> dim
val dim_shift_base_upto : dim -> num -> dim
val dim_inc_upto : dim -> num -> dim
val dim_dec_upto : dim -> num -> dim
val dim_resize_upto : dim -> num -> dim
val adjustment_ratio : dim -> num -> (num * int)
val dim_scale_badness : (num * int) -> num
val dim_scale : dim -> (num * int) -> dim
val dim_scale_upto : dim -> (num * int) -> dim
